package com.example.wechat;

import androidx.room.Entity;
import androidx.room.PrimaryKey;
//import androidx.PrimaryKey;
import androidx.room.Entity;

import java.util.Date;

@Entity(tableName = "messages")
public class Message {
    public static final int TYPE_TEXT = 1;
    public static final int TYPE_IMAGE = 2;
    public static final int TYPE_VOICE = 3;
    
    public static final int STATUS_SENDING = 1;
    public static final int STATUS_SENT = 2;
    public static final int STATUS_FAILED = 3;

    @PrimaryKey
    private String id;
    private String senderId;
    private String receiverId;
    private int type;
    private String content;
    private String imageUrl;
    private int voiceDuration;
    private String voiceUrl;
    private long timestamp;
    private int status;
    private boolean isRead;

    public Message() {
        this.id = String.valueOf(System.currentTimeMillis());
        this.timestamp = System.currentTimeMillis();
        this.status = STATUS_SENDING;
        this.isRead = false;
    }

    public Message(String id, String senderId, String receiverId, String content, Date timestamp, boolean isRead) {
        this.id = id;
        this.senderId = senderId;
        this.receiverId = receiverId;
        this.content = content;
        this.timestamp = timestamp.getTime();
        this.isRead = isRead;
    }

    // Getters and Setters
    public String getId() { return id; }
    public void setId(String id) { this.id = id; }

    public String getSenderId() { return senderId; }
    public void setSenderId(String senderId) { this.senderId = senderId; }

    public String getReceiverId() { return receiverId; }
    public void setReceiverId(String receiverId) { this.receiverId = receiverId; }

    public int getType() { return type; }
    public void setType(int type) { this.type = type; }

    public String getContent() { return content; }
    public void setContent(String content) { this.content = content; }

    public String getImageUrl() { return imageUrl; }
    public void setImageUrl(String imageUrl) { this.imageUrl = imageUrl; }

    public int getVoiceDuration() { return voiceDuration; }
    public void setVoiceDuration(int voiceDuration) { this.voiceDuration = voiceDuration; }

    public String getVoiceUrl() { return voiceUrl; }
    public void setVoiceUrl(String voiceUrl) { this.voiceUrl = voiceUrl; }

    public long getTimestamp() { return timestamp; }
    public void setTimestamp(long timestamp) { this.timestamp = timestamp; }

    public int getStatus() { return status; }
    public void setStatus(int status) { this.status = status; }

    public boolean isRead() { return isRead; }
    public void setRead(boolean read) { isRead = read; }
} 